package cn.wolfcode.crm.web.controller;

import cn.wolfcode.crm.domain.Permission;
import cn.wolfcode.crm.query.QueryObject;
import cn.wolfcode.crm.serivce.IPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("permission")
public class PermissionController {
    @Autowired
    private IPermissionService service;

    @RequestMapping("view")
    public String view() throws Exception {
        return "permission";
    }

    @RequestMapping("selectAll")
    @ResponseBody
    public List<Permission> selectAll() throws Exception {
        List<Permission> permissions = service.selectAll();
        return permissions;
    }
    @RequestMapping("selectByRoleId")
    @ResponseBody
    public List<Permission> selectByRoleId(Long roleId) throws Exception {
        List<Permission> permissions = service.selectByRoleId(roleId);
        return permissions;
    }
    @RequestMapping("reload")
    public void reload() throws Exception {
        service.reload();
    }
}
